/*
 * Copyright (C) 2008 nextcode:ch
 * 
 * Author: Michele Dell'Ambrogio, m@nextcode.ch
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as 
 * published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
package sfplayer.gui;

import java.awt.*;
import java.awt.event.*;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.*;

/**
 *
 * @author micc
 */
public class AboutBox extends JFrame implements ActionListener {

    protected JLabel titleLabel,  aboutLabel[];
    protected static int labelCount = 8;
    protected static int aboutWidth = 280;
    protected static int aboutHeight = 230;
    protected static int aboutTop = 200;
    protected static int aboutLeft = 350;
    protected Font titleFont,  bodyFont;
    protected ResourceBundle resbundle;

    public AboutBox() {

        super("");
        this.setResizable(false);
        resbundle = ResourceBundle.getBundle("sfplayer/resources/about", Locale.getDefault());

        SymWindow aSymWindow = new SymWindow();

        this.addWindowListener(aSymWindow);

        // Initialize useful fonts
        titleFont = new Font(resbundle.getString("Lucida_Grande"), Font.BOLD, 14);
        if (titleFont == null) {
            titleFont = new Font(resbundle.getString("SansSerif"), Font.BOLD, 14);
        }
        bodyFont = new Font(resbundle.getString("Lucida_Grande"), Font.PLAIN, 10);
        if (bodyFont == null) {
            bodyFont = new Font(resbundle.getString("SansSerif"), Font.PLAIN, 10);
        }

        this.getContentPane().setLayout(new BorderLayout(15, 15));

        aboutLabel = new JLabel[labelCount];
        aboutLabel[0] = new JLabel("");
        aboutLabel[1] = new JLabel(resbundle.getString("appName"));
        aboutLabel[1].setFont(titleFont);
        aboutLabel[2] = new JLabel(resbundle.getString("appVersion"));
        aboutLabel[2].setFont(bodyFont);
        aboutLabel[3] = new JLabel("");
        aboutLabel[4] = new JLabel("");
        aboutLabel[5] = new JLabel(resbundle.getString("copyright"));
        aboutLabel[5].setFont(bodyFont);
        aboutLabel[6] = new JLabel(resbundle.getString("authors"));
        aboutLabel[6].setFont(bodyFont);
        aboutLabel[7] = new JLabel("");

        Panel textPanel2 = new Panel(new GridLayout(labelCount, 1));
        for (int i = 0; i < labelCount; i++) {
            aboutLabel[i].setHorizontalAlignment(JLabel.CENTER);
            textPanel2.add(aboutLabel[i]);
        }
        this.getContentPane().add(textPanel2, BorderLayout.CENTER);
        this.pack();
        this.setLocation(aboutLeft, aboutTop);
        this.setSize(aboutWidth, aboutHeight);
    }

    class SymWindow extends java.awt.event.WindowAdapter {

        public void windowClosing(java.awt.event.WindowEvent event) {
            setVisible(false);
        }
    }

    public void actionPerformed(ActionEvent newEvent) {
        setVisible(false);
    }
}
